<template>
    <div class="headers_comment">
        <div class="l_head">
            <el-button style="margin-right: 20px;" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
            <el-breadcrumb separator="/">
                <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{ item.label }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r_head">
            <el-dropdown  @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="user" src="@/assets/user.png" alt="">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>个人中心</el-dropdown-item>
                    <el-dropdown-item  command="quit">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>

<script>
import {mapState} from 'vuex'
import Cookie from "js-cookie"
export default {
    data () {
        return {

 
        }
    },
    methods: {
        // 固定写法，使用vuex中的数据
        handleMenu() {
            this.$store.commit("changeIsCollapse");
        },
        handleCommand(command) {
            if(command === 'quit') {
                // 退出后清楚Cookie中的token和menu
                Cookie.remove('token');
                Cookie.remove('menu');
                this.$router.push('/login');
            }
        }
    },
    computed: {
        ...mapState({
            tags: state => state.tab.tabList
        })
    }
}
</script>
 
<style lang = "less" scoped>

.headers_comment {
    background-color: #333;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    .text {
        font-size: 14px;
        color: #fff;
        margin-left: 8px;
    }
    .user {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        cursor: pointer;
    }
    .l_head {
        display: flex;
        align-items: center;
        /deep/.el-breadcrumb__item {
            .el-breadcrumb__inner {
                font-weight: 400;
                color: #666;
                
            } 
            &:last-child {
                .el-breadcrumb__inner {
                    color: #fff;
                }
                
            }
        }
    }
}
</style>